<HTML><HEAD><TITLE>add_attribute(?Var, ?Attribute, +Module)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Term Manipulation</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>add_attribute(?Var, ?Attribute, +Module)</H1>
Add dynamically an attribute to a variable.


<DL>
<DT><EM>Var</EM></DT>
<DD>Any term.
</DD>
<DT><EM>Attribute</EM></DT>
<DD>Any term.
</DD>
<DT><EM>Module</EM></DT>
<DD>Integer or atom.
</DD>
</DL>
<H2>Description</H2>
   The main use of this predicate is for dynamic attributed variables
   creation.  Since the number of declared extensions can vary with time,
   attributes explicitly occurring in the source of extensions might be
   created with less slots than currently necessary.  To make sure that a
   newly created attributed variable will have as many slots as necessary,
   this predicate should be preferred to the equivalent

<P>
<PRE>
    Var = _{Attribute}
</PRE>
   If Var is a free variable, it will be bound to a new attributed variable
   whose attribute corresponding to Module will be Attribute.  If Var is
   already an attributed variable and the corresponding attribute is a free
   variable, it will be bound to Attribute.  Otherwise, if the attribute is
   not a free variable or if Var is instantiated, it will be unified with a
   new attributed variable whose corresponding attribute is Attribute and
   all other attributes are free variables.

<P>
   If Module is an atom, the attribute corresponding to a previous
   meta_attribute declaration will be used.  If Module is an integer, it is
   directly used as the index slot (this is mainly used by the compiler to
   resolve attribute references at compile time).

<P>

<H3>Modes and Determinism</H3><UL>
<LI>add_attribute(?, ?, +) is semidet
</UL>
<H3>Fail Conditions</H3>
Fails if Var is not a free variable and its unification with the new attributed variable fails
<H3>Exceptions</H3>
<DL>
<DT><EM>(270) undefined variable attribute </EM>
<DD>There is no attribute declared in Module.
</DL>
<H2>Examples</H2>
<PRE>
[eclipse 6]: meta_attribute(extra, []).

yes.
[eclipse 3]: add_attribute(X, a, extra), printf("%QPMw", X).
X{suspend : _g270 , extra : a}
X = X
yes




</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/termmanip/meta_attribute-2.html">meta_attribute / 2</A>, <A HREF="../../kernel/termmanip/add_attribute-2.html">add_attribute / 2</A>
</BODY></HTML>
